﻿CREATE PROCEDURE dbo.state_Verification_Init
(@LoanID int
)
AS
SET NOCOUNT ON

IF NOT EXISTS(SELECT * FROM t_VerificationSmart WHERE LoanID = @LoanID)
	INSERT INTO t_VerificationSmart(LoanID)VALUES(@LoanID)

DECLARE @ID int
SELECT @ID = V.ID FROM t_VerificationSmart V
INNER JOIN t_State_Parameters SP
ON V.StatusID = SP.StateID AND StateParameterID = dbo.fs_StateID__StateParameter__IsInActive()
WHERE V.LoanID = @LoanID

IF @ID > 0	EXEC state_VerificationSmart_Move @ID,0
